Grabber 
the program:  by Ali Ozer, NeXT Software Group
the example:  by Sharon Zakhour, NeXT Developer Support Team

Overview

This example shows how to create a TIFF file by reading the bits of a rectangular region from the screen.  This is accomplished using methods of the NXBitmapImageRep class.

To run Grabber:  position and re-size the window so that it covers the screen area you wish to TIFFify.  Select "Grab" from the menu.  A TIFF file called "screenshot.tiff" will appear in your current directory.  You may continue to select "Grab" and each time the screenshot.tiff file will be overwritten.  [Note:  a good enhancement to this example would be to replace this mechanism with a SavePanel.]

Program Organization

How to build the nib files
The nib file for Grabber consists of the main window 'Grabber' and the main menu.  The 'grabberWindow' outlet of the Grabber class is connected to the window via the File's Owner icon in the project window.  This is possible since the Grabber class is a subclass of Application.  Likewise the "Grab" menu button is connected to the grab: method of the Grabber class via the File's Owner icon.

How does all this grab ya?   :-)

Class[es] in the Application

Grabber 	Subclass of Application and only class in the example.   There are two methods in this class:  The setGrabberWindow: method is a good example of how to perform an explicit outlet initialization -- in this case the window used to define the region of interest for grabbing.

The grab: method,  called when the user selects "Grab" from the menu, will get the rectangle of the grabberWindow and read the information underneath that window into an instance of NXBitmapImageRep with the initData:forRect: method.  This data is written to a stream and then to disk.

Topics Of Interest

How to create a TIFF file using NXBitmapImageRep and streams.
NXBitmapImageRep is an image representation class used to manage TIFF and pixel-oriented images.  To create a TIFF file using this class, the data is first written to a stream and then the stream is written to a file.

How to initialize an outlet using the setMyOutlet method.
For every outlet created for a class  -- an implied setMyOutlet method exists but does not explicitly appear in the class code generated by IB.  In Grabber, for example, an outlet for the Grabber class called 'grabberWindow' was created in IB.  This outlet was connected to the window [aptly named 'Grabber'] which appears on startup.  

Other Files
Grabber.nib		The main nib file, the user-interface of the application.

Grabber_main.m,		Created by Interface Builder.
IB.proj,
Makefile,
Grabber.iconheader